<script setup lang="ts">
// import { useUserStore } from './stores/user'
import { useUserStore } from './stores'
import { request } from '@/utils/request'
import type { User } from './types/user'
const store = useUserStore()
// 测试响应拦截器
const login = async () => {
  // 登录请求 - 手机号 + 密码
  const res = await request<User>('/login/password', 'POST', {
    mobile: '13230000001',
    password: 'abc12345'
  })
  console.log(res.data)
  store.setUser(res.data)
}
// 测试请求拦截器
const getUser = async () => {
  // 获取用户信息 - 发送请求
  const res = await request('/patient/myUser')
  console.log('getUser', res)
}
</script>

<template>
  <div class="app-page">
    <div>用户信息: {{ store.user }}</div>
    <button @click="login">登录</button>
    <button @click="getUser">获取用户信息</button>
  </div>
</template>

<style lang="scss" scoped></style>
